package com.duoec.dw.lineage.dto;

import java.io.Serializable;
import java.util.Objects;
import java.util.Set;

/**
 * 表字段信息
 *
 * @author xuwenzhen
 */
public class TableFieldDto implements Comparable<TableFieldDto>, Serializable {
    /**
     * 序号
     */
    private Integer index;

    /**
     * 字段名称
     */
    private String colName;

    /**
     * 别名
     */
    private String alias;

    /**
     * 字段类型
     */
    private String dataType;

    /**
     * 字段描述
     */
    private String comment;

    /**
     * 血缘关系中用不到，在其它地方使用
     */
    private Set<String> tags;

    /**
     * 字段类型：1=普通字段 2=分区字段
     */
    private Integer fieldType;

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public String getColName() {
        return colName;
    }

    public void setColName(String colName) {
        this.colName = colName;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public Set<String> getTags() {
        return tags;
    }

    public void setTags(Set<String> tags) {
        this.tags = tags;
    }

    public Integer getFieldType() {
        return fieldType;
    }

    public void setFieldType(Integer fieldType) {
        this.fieldType = fieldType;
    }

    @Override
    public String toString() {
        return "[" + index + "]" + colName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof TableFieldDto)) {
            return false;
        }
        TableFieldDto that = (TableFieldDto) o;
        return index.equals(that.index) &&
                colName.equals(that.colName) &&
                Objects.equals(alias, that.alias);
    }

    @Override
    public int hashCode() {
        return Objects.hash(index, colName, alias);
    }

    @Override
    public int compareTo(TableFieldDto o) {
        return Integer.compare(this.getIndex(), o.getIndex());
    }
}
